//
//  WeakProxy.swift
//  TTCOM-iOS
//
//  Created by Toj on 11/8/22.
//

import UIKit

class WeakProxy: NSObject {

    public private(set) weak var target: NSObjectProtocol?
    
    public init(_ target: NSObjectProtocol?) {
        super.init()
        self.target = target
    }
    
    open override func responds(to aSelector: Selector!) -> Bool {
        return target?.responds(to:aSelector) == true
    }
    
    open override func forwardingTarget(for aSelector: Selector!) -> Any? {
        if target?.responds(to: aSelector) == true {
            return target
        }
        
        return super.forwardingTarget(for: aSelector)
    }
}
